package com.molin.networkTest.socketTest.tcpTest.demo1;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        //1.创建Socket对象
        ServerSocket serverSocket = new ServerSocket(8888);
        //2.等待客户端连接
        Socket accept = serverSocket.accept();

        //3.获得输入流对象
        InputStream is = accept.getInputStream();
        int b;
        while ((b=is.read())!=-1){
            System.out.print((char)b);
        }
        //4.释放资源
        is.close();
    }
}
